<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div id="app">
    <cpn></cpn>
</div>
<template id="cpn">
    <div>
        <h2>我是子组件的模板</h2>
        <button @click="visitParent">我是子组件里面的一个按钮</button>
    </div>
</template>
<script src="../js/vue.js"></script>
<script>
    const aaa = new Vue({
        el: "#app",
        data: {
            message: "hello,guys",
        },
        methods: {
        },
        components: {
            'cpn': {
                template: "#cpn",
                data() {
                    return{ }
                },
                methods: {
                    visitParent(){
                        console.log(this.$parent);
                        console.log(this.$parent.message);

                        console.log(this.$root);
                        console.log(this.$root.message);

                    }

                }
            }
        }
    })
</script>
</body>
</html>